def optimize_move(data: list[dict], min_time: float | int = 0.02):
    len_all = len(data) - 1
    now = 1
    while now <= len_all:
        data_now = data[now - 1]
        data_next = data[now]
        if data_now['type'] == 'move' and data_next['type'] == 'move':
            if data_next['time'] - data_now['time'] < min_time:  # 如果两个move事件间隔小于min_time，则删除前一个move事件
                del data[now]
                len_all -= 1
                now -= 1
        now += 1
    return data


def optimize_time(data: list[dict], length: int = 4):
    if data[0]['time'] == round(data[0]['time'], length):
        return data
    for i in range(len(data)):
        line = data[i]
        time = line['time']
        del line['time']
        line = {'time': round(time, length), **line}
        data[i] = line
    return data
